#include "CreateTextbox.h"


CreateTextbox::CreateTextbox(void)
{
}


CreateTextbox::~CreateTextbox(void){
	SDL_FreeSurface(screen);
	SDL_Quit();
}


void CreateTextbox::run(void){
	bool quit = false;
	const int WINDOW_WIDTH = 800;
	const int WINDOW_HEIGHT = 600;
	const char* WINDOW_TITLE = "Sample Textbox";
	
	// initialise the screen
	SDL_Init( SDL_INIT_VIDEO );
	TTF_Init();
	screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 32, 
      SDL_HWSURFACE | SDL_DOUBLEBUF );
	SDL_WM_SetCaption( WINDOW_TITLE, 0 );

	// create a textbox 
    Textbox *box = new Textbox(screen, 10, 10, 300, 25);
	box->drawBox(); // draw the box
	box->drawText();
   SDL_Event event;
    while(quit == false) {
        SDL_Delay(50);
        if(SDL_PollEvent(&event)) {
            box->handleEvent(&event); // pass the event to box1            
			if( event.type == SDL_QUIT ){
			//Quit the program
			quit = true;
			}
		}
        SDL_Flip(screen);
    }
}